﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Milkify.Data;

namespace Milkify.ComponentModel
{
    public class TaskListSortTypeConverter : TypeConverter
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(string))
                return true;
            return base.CanConvertTo(context, destinationType);
        }

        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                TaskListSort sort = (TaskListSort)value;
                switch (sort)
                {
                    case TaskListSort.Priority:
                        return "Priority";
                    case TaskListSort.Name:
                        return "Name";
                    case TaskListSort.Due:
                        return "Due date";
                    case TaskListSort.TimeEstimate:
                        return "Time estimate";
                    default:
                        return sort.ToString();
                }
            }
            return base.ConvertTo(context, culture, value, destinationType);
        }
    }
}
